#ifndef PYTHONSCRIPTABLEPLUGINOBJECT_H
#define PYTHONSCRIPTABLEPLUGINOBJECT_H

#define BOOST_PYTHON_STATIC_LIB
#define BOOST_PYTHON_STATIC_MODULE

#include <boost/python.hpp>

#include "CppNpObject.h"

namespace Awesomium
{
  class WebView;
};

/*!
Allow to represent a python object through the interface of NPObject.
Allow Javascript to call python methods.
*/
class PyNpObject : public CppNpObject
{
  boost::python::object m_object;

public:

  DECLARE_NPOBJECT_CLASS( PyNpObject )

  PyNpObject(Awesomium::WebView* view);
  virtual ~PyNpObject();

  virtual bool HasMethod(NPIdentifier name);
  virtual bool Invoke(NPIdentifier name, const NPVariant *args,
                      uint32_t argCount, NPVariant *result);
  virtual bool InvokeDefault(const NPVariant *args, uint32_t argCount,
                             NPVariant *result);

  virtual bool HasProperty(NPIdentifier name);
  virtual bool GetProperty(NPIdentifier name, NPVariant *result);
  virtual bool SetProperty(NPIdentifier name, const NPVariant *value);

  boost::python::object getPythonObject() const { return m_object; };

  void setPythonObject(boost::python::object const& object)
  { 
    m_object = object;
  };
};

boost::python::object convert(Awesomium::WebView* view, NPVariant const& v, NPObject* called_object=NULL, std::string const& method_name="");

extern "C" void initjs_to_python();

#endif